The present invention relates generally to object-based high level programming environments, and more particularly, to techniques for creating and maintaining objects in object oriented environments.
Recently, the Java™ programming environment has become quite popular. The Java™ programming language is a language that is designed to be portable enough to be executed on a wide range of computers ranging from small devices (e.g., pagers, cell phones and smart cards) up to supercomputers. Computer programs written in the Java programming language (and other languages) may be compiled into Java Bytecode instructions that are suitable for execution by a Java virtual machine implementation.
The Java virtual machine is commonly implemented in software by means of an interpreter for the Java virtual machine instruction set but, in general, may be software, hardware, or both. A particular Java virtual machine implementation and corresponding support libraries together constitute a Java™ runtime environment.
Computer programs in the Java programming language are arranged in one or more classes or interfaces (referred to herein jointly as classes or class files). Such programs are generally platform, i.e., hardware and operating system, independent. As such, these computer programs may be executed without modification on any computer that is able to run an implementation of the Java™ runtime environment.
Object-oriented classes written in the Java programming language are compiled to a particular binary format called the “class file format.” The class file includes various components associated with a single class. These components can be, for example, methods and/or interfaces associated with the class. In addition, the class file format can include a significant amount of ancillary information that is associated with the class. The class file format (as well as the general operation of the Java virtual machine) is described in some detail in The Java™ Virtual Machine Specification Second Edition, by Tim Lindholm and Frank Yellin, which is hereby incorporated herein by reference.
As an object-oriented programming language, Java utilizes the programming concept known as an object. In the Java programming environment, Java objects are created (instantiated) from Java classes. Typically, Java objects are stored in a heap memory portion (heap). A Java object in the heap can include a reference to its class, as well as one or more other fields describing data (e.g., variables) associated with the object. In addition, Java objects can include references to other Java objects.
During the execution of Java programs, some of the objects in the heap are no longer needed (i.e., become “dead objects” which are no longer reachable by the Java program). Accordingly, it is desirable to identify the “dead” objects and remove them from the heap. This operation can be referred to as “garbage collection.”
Conventionally, Java objects are allocated and maintained in the heap memory portion without regard to their traits. These traits, for example, include the class, size, life span, number of fields, whether objects reference other objects amount of time, and so forth. It should be noted that creation (instantiation) of Java objects requires several operations to be performed at run time. These operations include finding an appropriate place in the heap memory portion, calling the appropriate constructor and so forth. Performing these operations requires use of system resources. Moreover, the conventional arrangement of Java objects in the heap may result in inefficient use of system resources, especially, for systems with limited memory and/or computing power (e.g., embedded systems). As will be appreciated, this is partially attributed to the fact that Java objects in the heap memory portion can vary widely.
It should also be noted that the conventional arrangement of the heap memory portion can also adversely effects the maintenance of the Java objects. This means that there is a need for relatively more complex garbage collection programs. Again, inefficient use of memory space and/or resources can result since garbage collection programs require more memory and computing power to operate. As a result, performance of virtual machines, especially those with limited resources is limited.
In view of the foregoing, improved techniques for creating and maintaining objects in object oriented environments are needed.